Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
Delete a field from Firebase Firestore where the field/key has a period/punctuation (".") - modular v9 JavaScript SDK

This question is for a React Native Expo mobile App if that matters.

I have a flat database object. Using the documentation as an example:

  • https://firebase.google.com/docs/firestore/manage-data/delete-data

I have added a field/key called "example.com" with some arbitrary value. The object then looks like this:

{
capital: "words",
location: "other words",
"example.com": "more words"
}

I want to delete the key "example.com" key from the database, and I am using pretty much the same code as in the example from the documentation.

const cityRef = doc(db, "cities", "BJ");
const payload = {
    "example.com": deleteField(),
};
await updateDoc(cityRef, payload);

This does not delete the "example.com" key. I understand that this attempts to delete the "com" key from the "example" object within the main database document, which is not what I want, but I do not understand how to rework this code to treat the entire string as a key.

I have looked at some similar questions here on SO(links at the bottom) that came to the conclusion that they had to use FieldPath, but the syntax is outdated, and no longer works on the current version of Firestore(or at least I can not find the documentation for FieldPath for the version I am using, linked above).

And tips on how to get this working (deleting a field with a period) would be appreciated.

Link to similar problems:

  • Cannot update/delete Firestore field with "period" in the name
  • Cannot Delete Fields with Period in Key Name
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You still need to use FieldPath, but the API is different in the new v9 module SDK. You can see FieldPath in the API docs. Just import it along with any other functions that you use from the Firestore SDK.

I haven't used it myself, but based on the linked docs, my guess is that it works like this:

import { updateDoc, deleteField, FieldPath } from "firebase/firestore";
...
updateDoc(cityRef, new FieldPath("example.com"), deleteField());
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda